package edu.example.student.servlet;
import edu.example.common.PowerCheck;
import edu.example.student.dao.StudentDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/studentdelete")
public class StudentDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        /*权限*/
        if (!PowerCheck.isAdmin(req)) {
            req.setAttribute("reMessage", "无权访问");
            req.getRequestDispatcher("/error.jsp").forward(req, resp);
            return;
        }
        Integer stuid = Integer.parseInt(req.getParameter("id"));
        Integer code = new StudentDao().delete(stuid);
        req.setAttribute("delete", code);
        resp.sendRedirect("studentlist");
    }
}